-
Notifications
You must be signed in to change notification settings - Fork 6.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Iterator::Refresh() #2621
Add Iterator::Refresh() #2621
Conversation
Summary: Add and implement Iterator::Refresh(). When this function is called, if the super version doesn't change, update the sequence number of the iterator to the latest one and invalidate the iterator. If the super version changed, recreated the whole iterator. This can help users reuse the iterator more easily. Test Plan:Add a unit test.
@siying updated the pull request - view changes |
@siying has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!!!
lgtm.
HISTORY.md
Outdated
@@ -1,4 +1,8 @@ | |||
# Rocksdb Change Log | |||
## Unreleased | |||
### New Features | |||
* Add Iterator::Refresh(), which also users to bring the iterator state up-to-date and avoid some initialization costs of the iterator. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
may be rephrase this as: "... which allows users to update the iterator state ... "
@siying updated the pull request - view changes - changes since last import |
@siying has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator. |
@siying updated the pull request - view changes - changes since last import |
@siying has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator. |
|
||
InternalIterator* internal_iter = db_impl_->NewInternalIterator( | ||
read_options_, cfd_, sv, &arena_, db_iter_->GetRangeDelAggregator()); | ||
SetIterUnderDBIter(internal_iter); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This feels like not the duty of DBIter and feels to me could lead to future bugs if the db_impl called SetIterUnderDBIter in a different way and then we called it in our way.
If we are sure that we will always call SetIterUnderDBIter with an InternalIterator that looks like this
db_impl_->NewInternalIterator(read_options_, cfd_, sv, &arena_, db_iter_->GetRangeDelAggregator());
Then maybe we should have something like
DBIter::SetDBUnderIter(DBImpl* db_impl) {
InternalIterator* internal_iter = db_impl_->NewInternalIterator(read_options_, cfd_, sv, &arena_, db_iter_->GetRangeDelAggregator());
SetIterUnderDBIter(internal_iter);
}
And always use this function in db_impl.cc and make SetIterUnderDBIter private
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good suggestion. Let me try that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am trying this approach. SetDBUnderIter() needs to pass read_options, cfd, sv, etc. I'm feeling I'm getting things even more complicated.
Summary: Add and implement Iterator::Refresh(). When this function is called, if the super version doesn't change, update the sequence number of the iterator to the latest one and invalidate the iterator. If the super version changed, recreated the whole iterator. This can help users reuse the iterator more easily.
Test Plan:Add a unit test.